﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestWorkPart2
{
    class IntArray
    {
        private int[] myArray;
        private int firstIndex;
        private int arraySize;

        public IntArray(int arraySize, int firstIndex)
        {
            int[] myArray = new int[arraySize];
            this.firstIndex = firstIndex;
        }

        public int this[int index]
        {
            get
            {
                return myArray[index];
            }
            set
            {
                if (index < 0 && index > arraySize)
                {
                    if (firstIndex != 0)
                    {
                        myArray[index - firstIndex] = value;
                    }
                    else
                    {
                        myArray[index] = value;
                    }
                }
                else
                {
                    Console.WriteLine("Ошибка! Индекс за пределами допустимых значений.");
                }

            }
        }

        public int[] SumArrays(int[] array1, int[] array2)
        {
            int[] arrayResult = new int[array1.Length];
            for (int i = 0; i < array1.Length; i++)
            {
                arrayResult[i] = array1[i] + array2[i];
            }
            return arrayResult;
        }

        public int[] RandomiseArray(int[] array)
        {
            int[] myArray = new int[array.Length];
            Random rnd = new Random();
            for (int i = 0; i < array.Length; i++)
            {
                myArray[i] = rnd.Next(1,10);
            }
            return myArray;
        }

        public void PrintArray(int[] arrayToPrint)
        {
            for (int i = 0; i < arrayToPrint.Length; i++)
            {
                Console.Write("{0}\t", arrayToPrint[i]);
            }
            Console.WriteLine();
        }
    }
}
